package com.mycompany.inventory.util;

import java.util.LinkedHashMap;
import java.util.Map;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zul.Button;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;

import com.mycompany.inventory.pojo.Category;

public class CategoryComposer  {
	String[] keys = {"c1","c2","c3","c4","c5","c6","c7","c8","c9"};
	String[] icons = {"/images/Centigrade-Widget-Icons/FormsAndInputs-48x48.png","/images/Centigrade-Widget-Icons/LayoutAndWindows-48x48.png","/images/Centigrade-Widget-Icons/GridsAndTrees-48x48.png",
			"/images/Centigrade-Widget-Icons/ToolbarsAndMenus-48x48.png","/images/Centigrade-Widget-Icons/DataAndReport-48x48.png","/images/Centigrade-Widget-Icons/AjaxPushAnimation-48x48.png",
			"/images/Centigrade-Widget-Icons/EventsAndScripts-48x48.png","/images/Centigrade-Widget-Icons/MultimediaAndUtilities-48x48.png","/images/Centigrade-Widget-Icons/Miscellaneous2-48x48.png"};
	String[] label = {"Forms and Inputs","Layout and Windows","Grids and Trees","Toolbar and Menus","Data and Report","Ajax Push and Animation",
			          "Events and Scripts","Multimedia and Utilities","Miscellaneous"};
	
	Button _selected;
	
	Listbox itemList;
	
	public CategoryComposer(){
		for(int i = 0; i < keys.length; i++){
			Category cate = new Category(keys[i], icons[i], label[i], null);
			_cateMap.put(keys[i], cate);
		}
	}
	
	public void onCategorySelect(Button btn) {		
		Listitem item = null;
		if (_selected != btn) {
			_selected = btn;
		} 
		btn.setHref("j_spring_security_logout");
	}
	
	private static Map _cateMap = new LinkedHashMap () {
		 public Object remove(Object key) {
			 throw new UnsupportedOperationException();
		 }
		 public void clear() {
			 throw new UnsupportedOperationException();			 
		 }
	};
	
	private Map getCateMap() {
		return _cateMap;
	}
	
	private Map getCategoryMap() {
		return getCateMap();
	}
	
	public Category[] getCategories() {
		return (Category[]) getCategoryMap().values()
				.toArray(new Category[] {});
	}
	
	private Category getCategory(String cateId) {
		return (Category) getCategoryMap().get(cateId);
	}
}